// components/bottom-bar.js

const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    active:0,
    navbarInfo: [{
        index:0,
        icon: 'wap-home-o',
        title: '首页',
        href: '/pages/shop/shop'
      },
      { 
        index:1,
        icon: 'apps-o',
        title: '分类',
        href: '/pages/category/category'
      }, {
        index:2,
        icon: 'shopping-cart-o',
        title: '购物车',
        href: '/pages/cart/cart'
      }, {
        index:3,
        icon: 'friends-o',
        title: '我的',
        href: '/pages/index/index'
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    jump(e){
      const index  = e.currentTarget.dataset['index'];
      const url = e.currentTarget.dataset['url'];
      // if(this.data.active===index){
      //   return;
      // }
      this.setData({
        active:index
      })
      console.log(url);
      // wx.navigateTo({
      //   url: url,
      // })
      wx.switchTab({
        url: url,
      })
    }
  }
})